<template>
	<view class="profileBox">
		<view class="unLogin" v-if="!hasUserInfo">
			<button @click="login" class="loginBtn" type="primary">登录</button>
		</view>
		<view class="login" v-else>
			已登录
		</view>
	</view>
</template>

<script>
	const app = getApp()

	export default {
		name: 'profile',
		data() {
			return {
				hasUserInfo: false
			}
		},
		methods: {
			login() {
				// 调用登录函数
				app.login()
			}
		},
		onLoad() {
			const res = app.hasUserInfo()
			this.hasUserInfo = res
		},
		onPullDownRefresh(){
			const res = app.hasUserInfo()
			this.hasUserInfo = res
		}
	}
</script>

<style scoped lang="scss">
	.profileBox {

		.loginBtn {
			width: 60%;
			position: absolute;
			top: 50%;
			left: 50%;
			margin-top: -50rpx;
			margin-left: -30%;
		}
	}
</style>
